<template>

	<view v-if="">

		<view class="tab-nav">
			<!-- <ul class="tab-nav">
				<block v-for="(menuTab,index) in menuTabs" :key="index">
					<li v-bind:id="'tabNum'+index" @click="swichMenu(index)" :class="[current==index ? 'tab-nav-item tab-active' : 'tab-nav-item']">
						{{menuTab.name}}
					</li>
				</block>
			</ul> -->
			
			
			<u-tabs name="name" count="count" :list="menuTabs" :is-scroll="false" :current="current" @change="change">
			</u-tabs>
			<u-card v-for="(item,index) in menuLists" :title="item.dp[0].obuas.storeName" >
				<view slot="body">

					<template v-for="c in item.dp">
						<p>
							<!-- <image :src="c.pictureUrl"></image> -->
							<u-image width="50px" height="150rpx" :src="c.pictureUrl"></u-image>
						</p>
						<p>
						<h3>
							<u-icon size="34" color="" :label="c.orderDetailIntroduce"></u-icon>
						</h3>
						</p>
						<p>
						<h3>
							<u-icon size="34" color="" :label="c.count"></u-icon>
						</h3>
						</p>

					</template>
					
						<p>
							 实付款: ￥{{item.paymentMoney}}
						</p>
					
					<p>
					<h2>
						<u-icon size="34" color="#66CD00" :label="item.shippingCompName"></u-icon>
					</h2>
					</p>
					<template v-if="item.orderStatus==0">
						<u-button type="primary" size="mini" icon="el-icon-edit">待付款</u-button>
						<u-button type="success" size="mini" icon="el-icon-edit" @click="upDataById0(0)">去付款</u-button>
					</template>
					<template v-if="item.orderStatus==1">
						<!-- <u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataById1(1)">待发货</u-button> -->
						<u-button type="success" size="mini" icon="el-icon-edit" @click="upDataById1(1)">提醒卖家发货</u-button>
					</template>
					<template v-if="item.orderStatus==2">
						<u-button ref="uToast" type="primary" size="mini" icon="el-icon-edit" @click="upDataById2(2)">确认收货</u-button>
					</template>
					<template v-if="item.orderStatus==3">
						<u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataById3(3)">待评价</u-button>
						<u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataById3()">去评价</u-button>
						<u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataByIdTuiHuo(index)">申请退货</u-button>
					</template>
					<template v-if="item.orderStatus==4">
						<u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataById3(4)">退款售后</u-button>
					</template>
					<template v-if="item.orderStatus==5">
						<u-button type="primary" size="mini" icon="el-icon-edit" @click="upDataById3(5)">交易关闭</u-button>
					</template>
					

				</view>

			</u-card>
		</view>
	</view>


</template>
<script>
	import request from '../../../utils/request.js'
	export default {
		data() {
			return {
				payMoney:{
					userid: '',    //用户id
					detail: undefined, //商品id
					zonge: '',  //总价
					addressId: '',//地址id
					value: ''//数量
				},
				beforeUserId: undefined,
				orderId: undefined,
				current: 0,
				menuTabs: [{
					name: '全部'
					//count: 5,
				}, {
					name: '待付款'

				}, {
					name: '待发货'

				},{
					name: '待收货'

				},
				{
					name: '待评价'

				}, {
					name: '退款/售后',
					
				},{
					name: '已取消',
					
				}
				],
				menuLists: []

			}
		},
		onLoad() {
			uni.getStorage({
				key: 'beforeUser',
				success: (res) => {
					this.beforeUserId = res.data.beforeUserId
				}
			})
			this.getOrderBybeforUserIdList()
		},
		methods: {

			change(index) {
				this.current = index;
				if (this.current == 0) {
					request({
						url: '/order/bgs/order/OneOrderrUserId/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
							
						}
					})
				}
				if (this.current == 1) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus0/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
						}
					})
				
				}
				if (this.current == 2) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus1/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list 
						}
					})
				}
				if (this.current == 3) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus2/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
						}
					})
				}
				if (this.current == 4) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus3/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
						}
					})
				}
				if (this.current == 5) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus4/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
						}
					})
				}
				
				if (this.current == 6) {
					request({
						url: '/order/bgs/order/OneOrderrUserIdByStatus5/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list
						}
					})
				}
			},
			getOrderBybeforUserIdList() {
				if (this.current == 0) {
					request({
						url: '/order/bgs/order/OneOrderrUserId/' + this.beforeUserId,
						method: 'GET',
						success: (res) => {
							this.menuLists = res.data.data.list							
						}
					})
				}
			},
			upDataById0(index){
				
				/* payMoney:{
					userid: '',    //用户id
					detail: undefined, //商品id
					zonge: '',  //总价
					addressId: '',//地址id
					value: ''//数量
				}, */
				console.log(this.menuLists)
				this.payMoney.userid = this.beforeUserId
				console.log(this.payMoney.userid)
				this.payMoney.detail = this.menuLists[index].orderDetailId
				console.log(this.payMoney.detail)
				this.payMoney.zonge =  this.menuLists[index].paymentMoney
				console.log(this.payMoney.zonge)
				this.payMoney.addressId = this.menuLists[index].beforeUserAddrId
				console.log(this.payMoney.addressId)
				console.log(this.payMoney)
				/* uni.navigateTo({
					url:'../../pages/comment/index?return=' + this.payMoney
						}) */
				
			},
			upDataById1(row) {
				
			},
			upDataById2(row) {
				row = this.menuLists[0].orderId
				request({
					url: '/order/bgs/order/OneOrderUpdateIdByStatus/' + row,
					method: 'post',
					success: (res) => {
						
						uni.showToast({  
						 title:'收货成功！！评价有惊喜哦',  
						  icon:"none"  
						  });
						this.getOrderBybeforUserIdList()	
					}
				})		
				},
				
			upDataById3(row) {
				
			},
			upDataById4(row) {
				
			},
			upDataById5(row) {
				
			},

				/* 申请退货 */
			upDataByIdTuiHuo(index){
				console.log(this.menuLists[index]) 
			
				uni.navigateTo({
				url:'../../return/returngoods?paymentMoney=' + this.menuLists[index].paymentMoney+
				'&orderDetailId='+ this.menuLists[index].orderDetailId+'&orderId=' + this.menuLists[index].orderId
					})
			}
			
		}
	}
</script>

<style>
		@import '../../../static/css/style.css';
	.body {
		background: #FFFFFF;
		height: 40px;
		line-height: 40px;
		/* border-radius: 80px; */
		display: block;
		/* margin: 0 auto; */
		/* position: fixed; */
		width: 100%;
		margin-bottom: 15%;
		/* width: 185px; */
		z-index: 9999;
	}
</style>
